package cn.iocoder.yudao.module.iot.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.iot.dal.dataobject.IotPluginInstanceDO;
import cn.iocoder.yudao.module.iot.service.IotPluginInstanceService;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/iot/plugin-instance")
public class IotPluginInstanceController {
    @Resource
    private IotPluginInstanceService pluginInstanceService;

    @PostMapping("/create")
    public CommonResult<Long> create(@RequestBody IotPluginInstanceDO instance) {
        return CommonResult.success(pluginInstanceService.createPluginInstance(instance));
    }

    @PutMapping("/update")
    public CommonResult<Boolean> update(@RequestBody IotPluginInstanceDO instance) {
        pluginInstanceService.updatePluginInstance(instance);
        return CommonResult.success(true);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResult<Boolean> delete(@PathVariable Long id) {
        pluginInstanceService.deletePluginInstance(id);
        return CommonResult.success(true);
    }

    @GetMapping("/{id}")
    public CommonResult<IotPluginInstanceDO> get(@PathVariable Long id) {
        return CommonResult.success(pluginInstanceService.getPluginInstance(id));
    }

    @GetMapping("/list")
    public CommonResult<List<IotPluginInstanceDO>> list() {
        return CommonResult.success(pluginInstanceService.getPluginInstanceList());
    }
} 